package com.sooncode.project.focusservice.controller;

import com.sooncode.project.core.finder.Page;
import com.sooncode.project.focusservice.model.Sensory;
import com.sooncode.project.focusservice.service.SensoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("sensory")
public class SensoryController {
    @Autowired
    private SensoryService sensoryService;

    @PostMapping("sensory")
    public boolean add(@RequestParam Map<String,Object> map) {
        return sensoryService.add(map);
    }
    @PutMapping("sensory")
    public boolean modify(@RequestParam String id,@RequestParam Map<String,Object> map) {
        return sensoryService.modify(id,map);
    }
    @DeleteMapping("sensory")
    public boolean delete(@RequestParam String[] ids) {
        for (String id:ids)
            sensoryService.delete(id);
        return true;
    }
    @GetMapping("sensorys")
    public Page<Sensory> getPageList(@RequestParam int pageSize, @RequestParam int pageIndex, @RequestParam Map<String,Object> map) {
        map.remove("pageSize");
        map.remove("pageIndex");
        return sensoryService.getPageList(pageSize,pageIndex-1,map);
    }
}
